<?php
	// No direct access
	defined('_JEXEC') or die;
    jimport( 'joomla.application.component.view');
    class VolunteerViewEditlink extends JView
    {
		function display($tpl = null)
		{
			$linkId = JRequest::getVar('link');
			$this->assign( 'id', $linkId);
			
			$app = JFactory::getApplication();
			$data = $app->getUserState('volunteer.editlink.form.data');
						
			if($data['id'] == null || $data['id'] != $linkId) //load form for the first time
			{
				// echo 'hah';
				$model = $this->getModel('volunteer'); //get default model (volunteer)			
				//load data from db
				$link = $model->getLink($linkId);
				$this->assign( 'name', $link->name);
				$this->assign( 'url', $link->url);
			}
			else //form reload because of error
			{
				echo 'ha2h';
				 //display latest data from session
				$this->assign( 'name', $data['name']);
				$this->assign( 'url', $data['url']);
			}
			
			parent::display($tpl); //display defaul template
		}
    }